package com.css.fxfzdpzs.modules.qh.repository.impl;

import com.css.fxfzdpzs.modules.fxpg.entity.ActivityFaultData;
import com.css.fxfzdpzs.modules.qh.entity.*;
import com.css.fxfzdpzs.modules.qh.repository.QhRepository;
import com.css.fxfzdpzs.modules.qh.vo.ProjectDrillGeomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class QhRepositoryImpl implements QhRepository {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public ProjectDrillNum getProjectDrillNum() {
        String sql = "SELECT * FROM qh_project_drill_num";
        ProjectDrillNum num = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(ProjectDrillNum.class));
        return num;
    }

    @Override
    public List<ProvinceCount> getProvinceCount(String type) {
        String sql = "SELECT * FROM qh_province_count WHERE type ='" + type + "'";
        List<ProvinceCount> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ProvinceCount.class));
        return list;
    }

    @Override
    public List<ProjectDrillRenew> getProjectDrillRenew() {
        String sql = "SELECT * FROM qh_project_drill_renew";
        List<ProjectDrillRenew> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ProjectDrillRenew.class));
        return list;
    }

    @Override
    public List<YearProjectDrillRenew> getYearProjectDrillRenew() {
        String sql = "SELECT * FROM qh_year_project_drill_renew ORDER BY years";
        List<YearProjectDrillRenew> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(YearProjectDrillRenew.class));
        return list;
    }

    @Override
    public List<WorkCategoryCount> getWorkCategoryCount() {
        String sql = "SELECT * FROM qh_work_category_count";
        List<WorkCategoryCount> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WorkCategoryCount.class));
        return list;
    }

    @Override
    public List<ProjectDrillGeomVo> getLonAndLat() {
        String sql = "SELECT * FROM qh_project_drill_geom";
        List<ProjectDrillGeomVo> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ProjectDrillGeomVo.class));
        return list;
    }
}
